<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Feedback</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/bootstrap-responsive.css" rel="stylesheet">
    <link href="js/bootstrap.js" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>

<?php
include("/usr/local/apache2/htdocs/jibaiwang/lib/Feedback.php");
include("/usr/local/apache2/htdocs/jibaiwang/lib/Login.php");
include('log4php/Logger.php');
$cfgfile = "/usr/local/apache2/htdocs/jibaiwang/admin/bootstrap/conf/config.ini";
$defarray = parse_ini_file($cfgfile, 1);
$qlogtag = $defarray["Feedback"]['qlogtag'];
Logger::configure($defarray["Feedback"]['qlogcfg']);
$logger = Logger::getLogger($qlogtag);
$host = $defarray["Feedback"]["host"];
$user = $defarray["Feedback"]["user"];
$pass = $defarray["Feedback"]["pass"];
$db = $defarray["Feedback"]["db"];
$dbh = new Sqlexecutor($host, $user, $pass, $db);
$s = new Feedback($dbh,$logger);
$su = new Login($dbh,$logger);
$type_array = array("1"=>"投诉","2"=>"建议");
$status_array = array("1"=>"已回复","0"=>"未回复");
$list = $s->getList();
if($_REQUEST["op"] == "del")
{
    $res = $s->deleteByID($_REQUEST["rule_id"]);
    header("Location:Feedback.php");
}
if($_REQUEST["feedback"] == "on")
{
    $res = $s->replyByID($_REQUEST["rule_reply"],$_REQUEST["b_id"]);
    header("Location:Feedback.php");
}

?>
<legend>用户反馈中心</legend>
    <div class="span20">
      <table class="table table-striped">
        <thead>
          <tr>
            <th>#</th>
            <th>反馈内容</th>
            <th>回复内容</th>
            <th>状态</th>
            <th>类型</th>
            <th>反馈人</th>
            <th>反馈时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
<?php
    foreach($list as $key => $value)
    {
        $user_array = $su->getInfoByID($value["usrid"]);
        echo '<form class="well form-inline" target="_self">';
        echo "<tr>";
        echo '<td><input id="b_'.$value["id"].'" type="hidden" class="span1" name="b_id" readonly value="'.$value["id"].'">'.$value["id"].'</td>';
        echo '<input type="hidden" class="span1" name="feedback" readonly value="on">';
        echo '<td><textarea id="content_'.$value["id"].'" readonly name="content" class="span4" rows="5">'.$value["content"].'</textarea></td>';
        echo '<td><textarea id="content_'.$value["id"].'" name="rule_reply" class="span4" rows="5" >'.$value["reply"].'</textarea></td>';
        echo "<td>".$status_array[$value["status"]]."</td>";
        echo "<td>".$type_array[$value["type"]]."</td>";
        echo "<td>".$user_array["name"]."</td>";
        echo "<td>".$value["insert_date"]."</td>";
        echo "<td>";
        echo '<button class="btn btn-large btn-warning" type="submit" value="回复">回复</button>';
        echo '<a onclick="modify_del('.$value["id"].')" class="btn btn-large btn-danger" >删除</a>';
        //echo '<a onclick="modify_del('.$value["id"].')"><i class="icon-trash"></i> 删除</a>';
        echo "</td>";
        echo "</tr>";
        echo "</form>";
    }
?>
        </tbody>
      </table>
    </div>

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster
    <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> -->
    <script src="js/jquery.js"></script>
    <script src="js/google-code-prettify/prettify.js"></script>
    <script src="js/bootstrap-transition.js"></script>
    <script src="js/bootstrap-alert.js"></script>
    <script src="js/bootstrap-modal.js"></script>
    <script src="js/bootstrap-dropdown.js"></script>
    <script src="js/bootstrap-scrollspy.js"></script>
    <script src="js/bootstrap-tab.js"></script>
    <script src="js/bootstrap-tooltip.js"></script>
    <script src="js/bootstrap-popover.js"></script>
    <script src="js/bootstrap-button.js"></script>
    <script src="js/bootstrap-collapse.js"></script>
    <script src="js/bootstrap-carousel.js"></script>
    <script src="js/bootstrap-typeahead.js"></script>
    <script src="js/application.js"></script>
    <script src="js/customize.js"></script>

    <script type="text/javascript">
    function modify_del(id){
        if(window.confirm("确定删除吗？")){
            str="?op=del&rule_id="+id
                window.open(str,'_self');
        }
    }

    function modify_on(id,reply){
        if(window.confirm("确定回复吗？")){
            //str="?op=on&rule_id="+id
            str="?op=on&rule_id="+id+"&rule_reply="+reply
                window.open(str,'_self');
        }
    }
    </script>

    <script>
$('.carousel').carousel({
    interval: 12000
})
</script>

</body>
</html>
